package com.ftg.elvis.mapper;

import com.ftg.elvis.pojo.Menu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface AdminMenuMapper {

	@Select("select m.mid, m.menu_name menuName, m.menu_path menuPath, m.pare_menu_id pareMenuId from " +
			"user_role ur join role_menu rm on ur.role_id = rm.role_id " +
			"join menu m on rm.menu_id = m.mid where ur.user_id = #{arg0}")
	List<Menu> showAll(String uid);

	@Select("select count(*) from " +
			"user_role ur join role_menu rm on ur.role_id = rm.role_id " +
			"join menu m on rm.menu_id = m.mid where ur.user_id = #{arg0}")
	int getCount(String uid);

	@Select("select uid from user where username = #{username}")
    String findId(String username);
}
